package com.bai.hibernate;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by Admin on 2/17 0017.
 */
@Entity
@Table(name = "s_user", schema = "", catalog = "php_1")
public class SUser {
    private int id;
    private String name;
    private Date birthday;
    private Double salary;

    public SUser() {
    }

    public SUser(String name, Date birthday, Double salary) {
        this.name = name;
        this.birthday = birthday;
        this.salary = salary;
    }

    @Id
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Basic
    @Column(name = "birthday")
    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Basic
    @Column(name = "salary")
    public Double getSalary() {
        return salary;
    }

    public void setSalary(Double salary) {
        this.salary = salary;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SUser sUser = (SUser) o;

        if (id != sUser.id) return false;
        if (name != null ? !name.equals(sUser.name) : sUser.name != null) return false;
        if (birthday != null ? !birthday.equals(sUser.birthday) : sUser.birthday != null) return false;
        if (salary != null ? !salary.equals(sUser.salary) : sUser.salary != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (birthday != null ? birthday.hashCode() : 0);
        result = 31 * result + (salary != null ? salary.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "SUser{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", birthday=" + birthday +
                ", salary=" + salary +
                '}';
    }
}
